package com.jeeplus.cms.config.sitemesh;

import com.jeeplus.cms.common.CmsProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author WuXilin
 */
@Configuration
@DependsOn("springContextHolder")
public class SiteMeshConfig implements WebMvcConfigurer {

    @Autowired
    private CmsProperties cmsProperties;

    @Bean
    public FilterRegistrationBean<WebSiteMeshFilter> siteMeshFilter() {
        FilterRegistrationBean<WebSiteMeshFilter> filter = new FilterRegistrationBean<>();
        WebSiteMeshFilter siteMeshFilter = new WebSiteMeshFilter(cmsProperties.getFrontPath());
        filter.setFilter(siteMeshFilter);
        return filter;
    }
}
